public class T2_0906_0514 {
    private  static int count1 = 0;
    private static Count count2 = new Count();

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread() {
            @Override
            public void run() {
                for (int i = 0; i < 10000; i++) {
                    count2.increament();
            }
            }
        };
        Thread t2 = new Thread() {
            @Override
            public void run() {
                for (int i = 0; i < 10000; i++) {
                    count2.increament();
            }
            }
        };
        t1.start();
        t2.start();

        t1.join();
        t2.join();

        System.out.println(count2.count);
    }

    public static void main1(String[] args) throws InterruptedException {
        Object o = new Object();
        Thread t1 = new Thread() {
            @Override
            public void run() {
                for (int i = 0; i < 10000; i++) {
                    synchronized (o) {
                        count1++;
                    }
                }
            }
        };
        t1.start();
        for (int i = 0; i < 10000; i++) {
            synchronized (o) {
                    count1++;
            }
        }
        t1.join();
        System.out.println(count1);
    }
}
class Count {
    public int count = 0;
    public synchronized void increament() {
        count++;
    }
}